import { HTTP } from 'request'
import { FUNCTION_IDS } from 'tools/constant'
/**
 * 退出登录
 * @returns
 */
export const logOut = token => {
  return HTTP({
    method: 'get',
    url: `/oauth/logout?access_token=${token}`
  })
}

/**
 * 获取应用列表
 * @returns
 */
export const getApplication = roleId => {
  return HTTP({
    method: 'post',
    url: `/hlod/v1/mobile/menu/tree`,
    data: {
      roleId,
      functionIds: FUNCTION_IDS
    }
  })
}

/**
 * 获取用户信息
 * @returns
 */
export const getUserInfo = () => {
  return HTTP({
    method: 'get',
    url: '/iam/hzero/v1/users/self'
  })
}

/**
 * 获取租户列表
 * @returns
 */
export const getTenantsList = () => {
  return HTTP({
    method: 'get',
    url: '/iam/hzero/v1/users/self-tenants'
  })
}

/**
 * 获取角色列表
 * @returns
 */
export const getRolesList = () => {
  // return com.$dsxFetch.fetch.get(
  //   'http://modtestb.saas.hand-china.com/iam/hzero/v1/users/self-tenants'
  // )
  return HTTP({
    method: 'get',
    url: '/iam/hzero/v1/member-roles/self-roles'
  })
}

/**
 * 修改角色
 * @returns
 */
export const editRole = roleId => {
  return HTTP({
    method: 'put',
    url: `/iam/v1/users/roles?roleId=${roleId}`
  })
}

/**
 * 修改租户平台
 * @returns
 */
export const editTenant = tenantId => {
  return HTTP({
    method: 'put',
    url: `/iam/v1/users/tenant-id?tenantId=${tenantId}`
  })
}
